﻿/*
 *
 * Images fullPlay
 * Author: Join Fisher
 * Version: 1.0 (1-Jun-2016)
 *
 */

(function($) {

    $.fn.fullImages = function(fisher) {

        var fisher = $.extend({
            ImgWidth: null,
            ImgHeight: null,
            autoplay: null,
            fadeTime: null,
            minWidth: null,
            imgWrapperClass: null,
            dotClass: null,
            dotActiveClass: null
        },
        fisher)

        var count = $(this).find("img").length; 
        var nValue = 0;
        var oValue = 0;
        var _this = $(this);
        var imgWraper = _this.find('.' + fisher.imgWrapperClass)
        var dotsDom = _this.find('.' + fisher.dotClass)
        imgWraper.find("img:eq(0)").fadeIn("slow");
        var setIntervalImg = setInterval(function() {

            nValue++
            if (nValue == count) {
                nValue = 0;
            }
            imgWraper.find(" img:eq(" + (nValue) + ")").fadeIn(fisher.fadeTime);
            imgWraper.find(" img:eq(" + (oValue) + ")").fadeOut(fisher.fadeTime);
            oValue = nValue % count;
            dotsDom.removeClass(fisher.dotActiveClass)
            dotsDom.eq(nValue).addClass(fisher.dotActiveClass)
        },
        fisher.autoplay);

        resizeFun();
        $(window).resize(function(e) {
            resizeFun();
        });

        function resizeFun() {

            /*轮播图全屏*/
            var wraperWidth = $(this).width()
            if (wraperWidth >= fisher.minWidth) {
                _this.find("img").css("width", wraperWidth);
            } else {
                _this.find("img").css("width", fisher.minWidth);
            }
        }
    };

} (jQuery));